<template>
  <div>

    <div slot="header" class="clearfix">
      <span style="float: left; padding: 3px 0">违规外联监控策略列表</span>
      <el-button style="float: right; padding: 3px 0" icon="el-icon-refresh" type="text" @click="Refresh">刷新</el-button>
    </div>

    <com-table :tableData="tableData" url="app" keyName="app" :has-data="hasData" :table-head-list="tableHeadList"
      :total-count="totalCount" :page-num="pageNum" :page-size="pageSize" :page-sizes="pageSizes"
      :table-loading="loading" :table-height="tableHeight" :is-show-select="true" :page-show="false" :handle-show="true"
      :merge-flag="false" :modifys="true" :baddtsd="false" @setSearchHeight="setTableHeight" @openDialog="openDialog"
      :deletebtn="false" :ifShowOnline="true" addOnline="状态" @isOnline="isOnline" ref="comTable">
    </com-table>

  </div>
</template>
<script>
import ComTable from "../../components/table/comTable";

export default {
  name: "mabDevice",
  data() {
    return {
      pageNum: 1,
      pageSize: 10,
      pageSizes: [5, 10, 20, 100],
      totalCount: 0,
      tableData: [], // 表格数据
      options: [],
      tableHeight: "", // 表格高度
      dialogTitle: "",
      hasData: true,
      loading: false, // 数据加载状态遮罩
      checkList: [],
      tableHeadList: [
        { columnComment: "策略名称", columnName: "name", colDisabled: false, colHidden: false, colSearch: true, colSort: false, },
        // { columnComment: "状态", olumnName: "state", typeCollection: "stateEnum", colDisabled: false, colHidden: false, colSearch: true, colSort: false, },
        { columnComment: "创建人", columnName: "creator", colDisabled: false, colHidden: false, colSearch: true, colSort: false, },
        { columnComment: "创建时间", columnName: "enableTime", colDisabled: false, colHidden: false, colSearch: true, colSort: false, },

      ],
      dialogControl: false,
    };
  },
  components: {
    ComTable,
  },
  created() {
    this.setTableHeight()
    this.getTableData()
  },
  methods: {
    isOnline(val, row) {
      console.log(val, row, "34");
      let params = {
        Root: row.Root,
        creator: "secadm",
        enableTime: "",
        name: row.name,
        state: val,
      }
      this.$postForJson('3in1/policy/violation', params).then(jsonData => {
        console.log(jsonData, "sss");
        this.$message({
          type: "success",
          message: "提交成功！",
        });
        this.getTableData()
      })

    },
    //刷新
    Refresh() {
      this.getTableData()
    },
    getTableData() {
      this.$get('3in1/policy/violation').then(jsonData => {
        console.log(jsonData, "sss");
        this.tableData = jsonData.data.data
      })
    },
    //新建与修改
    openDialog(type, row) {
      console.log('aaa');
      this.$router.push({
        path: '/Violationform',
        name: 'Violationform',
        params: row
      });
    },
    dialogClosed() { },
    addTerminal() {
      this.dialogControl = false;
      this.$message({
        type: "success",
        message: "新增成功！",
      });
    },
    modifyTerminal() {
      this.dialogControl = false;
      this.$message({
        type: "success",
        message: "修改成功！",
      });
    },
    delegods() {
      this.$confirm("确认删除？", "提示", {
        confirmButtonText: "确 定",
        cancelButtonText: "取 消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功！",
          });
        })
        .catch((_) => { });
    },
    setTableHeight() {
      let clientHeiht =
        window.innerHeight || document.documentElement.clientHeight;
      this.tableHeight = clientHeiht - 110;
    },
  },
};
</script>

<style scoped>
.el-checkbox-group {
  display: flex;
  flex-direction: column;
}
.el-select {
  width: 100%;
}
.el-date-editor.el-input,
.el-date-editor.el-input__inner {
  width: 100%;
}
</style>